/*
 * @Author: DaQing Lu
 * @Date: 2020-01-24 14:15:34
 * @LastEditors: DaQing Lu
 * @LastEditTime : 2020-02-15 11:33:42
 * @Description: file content
 */
import React, {useEffect, useState} from 'react';
import {Button, Table, Tag} from 'antd';

function UnpaidOrderList(props) {
  console.log(props);
  const [columns, setColumns] = useState([
    {
      title: '订单号',
      dataIndex: 'order_no',
      key: 'order_no'
    }, {
      title: '下单时间',
      dataIndex: 'create_at',
      key: 'create_at'
    }, {
      title: '付款总金额',
      dataIndex: 'goods_price',
      key: 'goods_price'
    }, {
      title: '运费',
      dataIndex: 'freight_price',
      key: 'freight_price'
    }, {
      title: '采购公司',
      dataIndex: 'company_name',
      key: 'company_name'
    }, {
      title: '状态',
      dataIndex: 'status',
      render: (status, record) => {
        // 订单状态(1已支付订单2已发货订单【部分或者全部发货】3订单完成4未确认收款)
        return <div className='BeforeOperatedAction'>
          {
            status === 0 && <Tag size='small' color={'gold'}>未支付订单</Tag>
          }
          {
            status === 1 && <Tag size='small' color={'gold'}>已支付订单</Tag>
          }
          {
            status === 2 && <Tag size='small' color={'green'}>已发货订单</Tag>
          }
          {
            status === 3 && <Tag size='small' color={'blue'}>订单完成</Tag>
          }
          {
            status === 4 && <Tag size='small' color={'magenta'}>未确认收款</Tag>
          }
          {
            status === 5 && <Tag size='small' color={'#f50'}>订单超时失效</Tag>
          }
        </div>;
      }
    }, {
      title: '备注',
      dataIndex: 'remark',
      key: 'remark'
    }, {
      title: '操作',
      key: 'action',
      render: (text, record) => {
        // review: 1
        return <div className='BeforeOperatedAction'>
          <Button size={'small'} type={'primary'} onClick={() => props.details(text.order_no)}>详情</Button>
          {
            text.modify === 0 &&
            <Button size={'small'} type={'danger'}
                    onClick={() => props.edit(text.order_no, text.goods_price, text.freight_price, text.remark)}>修改</Button>
          }

          {
            text.audit === 0 &&
            <Button size={'small'} type="dashed" onClick={() => props.audit(text.refund_no)}>审核</Button>
          }

        </div>;
      }
    }

  ]);

  return (
    <div className={'SupplierOrderList'}>
      <Table dataSource={props.unpaidOrderList} columns={columns} pagination={false}/>
    </div>
  );
}

export default UnpaidOrderList;
